package com.yfbao.horizon.schedule.tk.conf;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@Configuration
@EnableConfigurationProperties({PrometheusProperties.class})
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnProperty(value = "seeyon.prometheus.enable", matchIfMissing = true)
@Slf4j
public class PrometheusAutoConfiguration {

    @Bean
    MeterRegistryCustomizer meterRegistryCustomizer() {
        return registry -> {
            log.info("启用Prometheus监控，application:{}", "horizon");
            registry.config().commonTags("application",  "horizon");
        };

    }
}
